<?php if (!defined('THINK_PATH')) exit();?><section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-danger">
                <div class="box-body">
                    <form id="admin_rolelist_permission_dialog_form"
                          onsubmit="return adminRolePermissionDialogFormSubmit()">
                        <ul id="admin_rolelist_permission_dialog_form_tree" class="easyui-tree"
                            data-options="url:'<?php echo U('Admin/rolePermission?id='.$id);?>',method:'post',animate:true,checkbox:true,lines:true"></ul>
                        <div class="box-footer" style="margin-top: 50px">
                            <span class="input-group-btn">
                                <button class="btn btn-danger pull-left" type="button" id="close-dialog">取消</button>
                                <button class="btn btn-primary pull-right" type="button" id='form_submit' onclick="adminRolePermissionDialogFormSubmit()">提交</button>
                            </span>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</section>

<script type="text/javascript">
    function adminRolePermissionDialogFormSubmit() {
        var nodes = $('#admin_rolelist_permission_dialog_form_tree').tree('getChecked');
        var menuids = [];
        for (var i = 0; i < nodes.length; i++) {
            menuids.push(nodes[i]['id']);
            menuids.push(nodes[i]['attributes']['parent']);
        }
        $.post("<?php echo U('Admin/rolePermission?dosubmit=1&id='.$id);?>", {menuids: menuids.join(',')}, function (res) {
            if (!res.status) {
                $.messager.alert('提示信息', res.info, 'error');
            } else {
                $.messager.alert('提示信息', res.info, 'info');
                dialog.get('dialogPage').close().remove();
                reloadContent();
            }
        });
        return false;
    }

    //格式化
    $('#admin_rolelist_permission_dialog_form_tree').tree();
</script>